/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package com.xzw.thrift;

import com.xzw.thrift.User;

import com.xzw.thrift.UserNotFound;

import com.xzw.thrift.UserService;

import java.util.ArrayList;

import java.util.List;

import java.util.logging.Logger;

import org.apache.thrift.TException;

/**

 *

 * @author xzw

 */

public class UserServiceHandler implements UserService.Iface{

public User getUser(String loginName) throws UserNotFound, TException {

        if(!"xuzhiwei".equals(loginName)){

        UserNotFound e = new UserNotFound("用户无法找到！");

        throw e;

        }

        User user = new User();

        user.setUserId(100);

        user.setLoginName("xuzhiwei");

        user.setPassword("123456");

        user.setName("user1");

        Logger.getLogger("user=>"+user.toString());

        return user;

        }

public List<User> getUsers() throws TException {

        List<User> list = new ArrayList<User>();

        User user = new User();

        user.setUserId(100);

        user.setLoginName("xuzhiwei");

        user.setPassword("123456");

        user.setName("user1");

        list.add(user);

        User user2 = new User();

        user2.setUserId(200);

        user2.setLoginName("login2");

        user2.setPassword("pwd2");

        user2.setName("user2");

        list.add(user2);

        Logger.getLogger("user list=>"+list.toString());

        return list;

        }

        }
